-
Notifications
You must be signed in to change notification settings - Fork 60
api: add events subscription support #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dd9a1fa
to
22455f6
Compare
There are few things to do after #226 will be merged into
But it doesn't look critical and can be done quickly. This will not affect the idea of the pull request. |
dafb5e1
to
401de6d
Compare
It is better to refer to /en/ documentation. |
401de6d
to
3240a5a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've try to review it one more time later. It's rather hard to catch on all these concurrency details from the first time (especially if you're not familiar with them).
Thank you! I could recommend to review in this order:
It would be possible to split the commit into several (Connection, ConnectionMulti, ConnectionPool, Connector), but it look like a single feature, so I did not do it. |
3240a5a
to
2725aa3
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, thx for patch. I am generally ok, just some small comments.
672e012
to
f3691d1
Compare
I'm still a bit confused. If a watcher subscribed for a key that has been broadcasted before the subscription, will callback be triggered twice? If yes, with which values? Or will it be triggered for each historical value in their order? Or will it trigger only once for the current key value? If yes, I don't get what "If a watcher is subscribed for a key that has not been broadcast yet, the callback is triggered only once" should mean since they all are triggered only once on bootstrap. |
It is copy-paste from: https://www.tarantool.io/ru/doc/latest/reference/reference_lua/box_events/#how-a-watcher-works I think I need to look at the whole paragraph. The last sentence explains what will happen if there are no broadcasts yet. But I can delete the sentence =) |
6620388
to
4662c58
Compare
f4b4d71
to
706b3e6
Compare
706b3e6
to
a719437
Compare
cda1f1a
to
c3e2254
Compare
e496d79
to
c3925d0
Compare
Due to a bug [1], our test workflow fails on Tarantool 1.10. It is a quick fix until the problem is fixed. 1. tarantool/setup-tarantool#37
The patch removes a last newline character from log messages because the character will be added anyway [1][2]. 1. https://pkg.go.dev/log#Logger.Printf 2. https://pkg.go.dev/log#Output Part of #119
A user can create watcher by the Connection.NewWatcher() call: watcher = conn.NewWatcker("key", func(event WatchEvent) { // The callback code. }) After that, the watcher callback is invoked for the first time. In this case, the callback is triggered whether or not the key has already been broadcast. All subsequent invocations are triggered with box.broadcast() called on the remote host. If a watcher is subscribed for a key that has not been broadcast yet, the callback is triggered only once, after the registration of the watcher. If the key is updated while the watcher callback is running, the callback will be invoked again with the latest value as soon as it returns. Multiple watchers can be created for one key. If you don’t need the watcher anymore, you can unregister it using the Unregister method: watcher.Unregister() The api is similar to net.box implementation [1]. It also adds a BroadcastRequest to make it easier to send broadcast messages. 1. https://www.tarantool.io/en/doc/latest/reference/reference_lua/net_box/#conn-watch Closes #119
c3925d0
to
bc79947
Compare
A user can create watcher by the Connection.NewWatcher() call:
After that, the watcher callback is invoked for the first time. In this case, the callback is triggered whether or not the key has already been broadcast. All subsequent invocations are triggered with box.broadcast() called on the remote host. If a watcher is subscribed for a key that has not been broadcast yet, the callback is triggered only once, after the registration of the watcher.
If the key is updated while the watcher callback is running, the callback will be invoked again with the latest value as soon as it returns.
Multiple watchers can be created for one key.
If you don’t need the watcher anymore, you can unregister it using the Unregister method:
The api is similar to net.box implementation [1].
It also adds a BroadcastRequest to make it easier to send broadcast messages.
I didn't forget about (remove if it is not applicable):
Related issues:
Closes #119